using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Gadgets.Trading
{
    public partial class eOrdersMatched : WeifenLuo.WinFormsUI.Docking.DockContent 
    {
        public eOrdersMatched()
        {
            InitializeComponent();
        }

        private void eOrdersMatched_Load(object sender, EventArgs e)
        {
            ABSCommonLibrary.CreateGridView(ref gridControl1);
            colDATE_CREATED.FormatSpecifier = DeclareLibrary.DATE_DISPLAY_FORMAT;
            colVOLUME.FormatSpecifier = DeclareLibrary.NUMBER_FORMAT;
            colPRICE.FormatSpecifier = DeclareLibrary.NUMBER_FORMAT;
            
        }

        private void eOrdersMatched_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F9)
            {                
                string board_id = string.Empty;                
                if (valueRow1.Cells["BOARD_ID"].Value != null)
                    board_id = valueRow1.Cells["BOARD_ID"].Value.ToString();
                
                DataSet normal_order = ABSCommonLibrary.DoInquiry(
                    CommonLibrary.CommonLibrary.BOSC002011,
                    new object[2] {board_id, DeclareLibrary.MARKET_DAY});
                gridControl1.SetDataBinding(normal_order, normal_order.Tables[0].TableName);
            }
            else if (e.KeyCode == Keys.F10)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                saveFileDialog.Filter = "Excel Files (*.xls)|*.xls";
                saveFileDialog.AddExtension = true;
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    string FileName = saveFileDialog.FileName;
                    // TODO: Add code here to save the current contents of the form to a file.
                    Xceed.Grid.Exporting.ExcelExporter export = new Xceed.Grid.Exporting.ExcelExporter();
                    export.Export(gridControl1, FileName);
                }
            }
        }
    }
}